package com.ideaaedi.zoo.example.springboot.seata.beta.controller;

import com.ideaaedi.zoo.example.springboot.seata.beta.service.SysRoleService;
import io.seata.core.context.RootContext;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Hidden
@RestController
@RequestMapping("/role")
@Tag(name = "测试入口在service-alpha的controller中")
public class RoleController {
    
    @Resource
    private SysRoleService sysRoleService;
    
    @Resource
    private HttpServletRequest httpServletRequest;
    
    /**
     * 随机添加角色
     */
    @GetMapping("/random-add")
    public void randomAddUser() {
        System.err.println(
                "全局事务id传递过来啦： " + httpServletRequest.getHeader(RootContext.KEY_XID)
        );
        sysRoleService.randomAddRole();
    }
}
